package com.dc.controller;


import com.dc.annotation.UnCheckToken;
import com.dc.common.ResponseResultVO;
import com.dc.entity.ro.SysUserLoginRO;
import com.dc.service.SysUserLoginService;
import com.dc.vo.SysUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sysUser")
@Api(tags = "后台用户相关接口")
public class SysUserLoginController {

    @Resource
    SysUserLoginService sysUserLoginService;

    @ApiOperation(value = "登录", notes = "用户")
    @PostMapping(value = "/login")
    @UnCheckToken(name = "/dc-control-system", url = "/sysUser/login")
    public ResponseResultVO sysUserLogin(@RequestBody SysUserLoginRO sysUserLoginRO) {
        return sysUserLoginService.sysUserLogin(sysUserLoginRO);
    }

    @ApiOperation(value = "注销", notes = "注销")
    @GetMapping("/logout")
    public ResponseResultVO logout() {
        return sysUserLoginService.logout();
    }

    @ApiOperation(value = "获取图片验证码", notes = "获取图片验证码")
    @GetMapping(value = "/captcha")
    @UnCheckToken(name = "/dc-control-system", url = "/sysUser/captcha")
    public ResponseResultVO captcha() {
        return sysUserLoginService.captcha();
    }

    @ApiOperation(value = "通过token获取用户信息", notes = "通过token获取用户信息")
    @GetMapping(value = "/getUserByToken")
    public ResponseResultVO<SysUserVO> getUserByToken() {
        return sysUserLoginService.getUserByToken();
    }


}
